/**模板 */const mongoose = require('../db')
//用户表
const UserSchema = new mongoose.Schema({
    username: {//用户名
        type: String, // 字段类型
        required: true, // 不能为空
    },
    password: {//密码
        type: String,
        required: true, // 不能为空
    },
    name: {//姓名
        type: String,
        required: true
    },
    sex: {//性别
        type: String,
        required: true
    },
    idCard: {//身份证
        type: String,
        required: true
    },
    phone: {//手机号码
        type: Number,
        required: true
    },
    birthday: {//生日
        type: String,
        required: true
    },
    nickname: {//职称
        type: String,
        required: true
    },
    role: {//角色
        type: String,
        required: true
    },
    Campus: {//院区
        type: String,
        required: true
    },
    department: {//科室
        type: String,
        required: true
    },
    status: {//用户状态
        type: Boolean,
        required: true
    }
})
const UserModel = mongoose.model('UserModel', UserSchema, 'UserModel')

//医院表
const HospitalSchema = new mongoose.Schema({
    name: {//医院名称
        type: String,
        required: true

    }
})
const hospitalModel = mongoose.model('HospitalModel', HospitalSchema, 'HospitalModel')

//科室表
const DepartmentSchema = new mongoose.Schema({
    name: {//科室名称
        type: String,
        required: true
    },
    hospital: {//所属医院
        type: mongoose.Types.ObjectId,
        required: true
    }
})
const DepartmentModel = mongoose.model('DepartmentModel', DepartmentSchema, 'DepartmentModel')

//角色表
const RoleSchema = new mongoose.Schema({
    name: {//角色名称
        type: String,
        required: true
    },
    status: {//角色状态
        type: Boolean,
        required: true
    },
    department: {//所属科室
        type: mongoose.Types.ObjectId,
        required: true
    }
})
const RoleModel = mongoose.model('RoleModel', RoleSchema, 'RoleModel')

//职位表
const PositionSchema = new mongoose.Schema({
    name: {//职位名称
        type: String,
        required: true
    },
    status: {//角色状态
        type: Boolean,
        required: true
    },
    role: {//所属角色
        type: mongoose.Types.ObjectId,
        required: true
    }
})
const PositionModel = mongoose.model('PositionModel', PositionSchema, 'PositionModel')

//权限表
const PermissionSchema = new mongoose.Schema({
    name: {//权限名称
        type: String,
        required: true
    },
    position: {//所属职位
        type: mongoose.Types.ObjectId,
        required: true
    }
})
const PermissionModel = mongoose.model('PermissionModel', PermissionSchema, 'PermissionModel')



module.exports = {
    UserModel,
    hospitalModel,
    DepartmentModel,
    RoleModel,
    PositionModel,
    PermissionModel
}

